<template>
    <div class="myOrder-box">
        <div class="title">我的订单记录</div>
        <div class="table-box">
            <div class="table-th">
                <div class="c_name">课程订单</div>
                <div class="c_item">支付方式</div>
                <div class="c_item">价格</div>
                <div class="c_item">状态</div>
                <div class="c_item">操作</div>
            </div>
            <div class="table-body" v-infinite-scroll="init" style="overflow:auto" infinite-scroll-disabled="disabled">
                <div class="table_item" v-for="(item,index) in listData" :key="index">
                    <div class="order-info">订单编号：{{item.order_no}} {{item.created_at}}</div>
                    <div class="order-item">
                        <div class="c_name">
                            <img :src="item.video_course.full_cover"
                                style="max-width: 120px; height: 80px;border-radius: 10px;vertical-align: middle;">
                            <span>{{item.title}}</span>
                        </div>
                        <div class="c_item o_item">{{paytype(item.pay_type)}}</div>
                        <div class="c_item o_item" style="color: #FF6D6A;">{{item.pay_amount}}</div>
                        <div class="c_item o_item">1</div>
                        <div class="c_item btns">
                            <div class="btn btn0">立即付款</div>
                            <div class="btn btn1">取消订单</div>
                            <!-- <div class="btn">去学习</div>
                            <div class="btn">申请售后</div>
                            <div class="btn">删除订单</div> -->
                        </div>
                    </div>
                </div>
            </div>
            <p v-if="loading">加载中...</p>
            <p v-if="noMore">没有更多了</p>
        </div>
    </div>
</template>
<script>
import { getOrderlist,getCancelOrder,getDelOrder} from '@/api/user.js';
export default {
    data() {
        return {
            page:0,
            listData:[],
            loading: false,
            isLoading:[]
        }
    },
    computed: {
      noMore () {
        return this.isLoading.length < 10
      },
      disabled () {
        return this.loading || this.noMore
      },
      
    },
    mounted() {
        this.init()
    },
    methods: {
        init() {
            this.page++
            let that = this
            that.loading = true
            getOrderlist({page:this.page}).then(res=>{
                console.log(88,res)
                let list = res.list
                if(list.length < 10) {
                    that.isLoading = list
                }
                if (list.length != 0) {
                    list.map(item=>{
                        that.listData.push(item)
                    })
                }
                that.loading = false
            })
        },
        paytype(type) {
        if (type == 0) return '未知';
        if (type == 1) return '微信';
        if (type == 2) return '抖音';
        if (type == 3) return '支付宝';
      }
    },
}
</script>
<style lang="scss" scoped>
.myOrder-box {
    margin: 1.5% 12.5%;
    background-color: #fff;
    padding: 1.5%;
}

.table-box {
    margin-top: 1.5%;

    .table-th {
        display: flex;
        justify-content: space-between;
        border: #E6E6E6 1px solid;
        border-radius: 10px;
        padding: 0.8%;
    }

    .table_item {
        border: #E6E6E6 1px solid;
        border-radius: 10px;
        // padding:0 0.8%;
        margin-top: 1.5%;

        .order-info {
            background-color: #F5F5F5;
            padding: 0.8%;
        }

        .order-item {
            padding: 0.8%;
            display: flex;
        }

        .btns {
            height: 80px;
            display: flex;
            flex-wrap: wrap;
            flex-direction: column;
            align-items: center;
            justify-content: space-around;
        }

        .btn {
            cursor: pointer;
            width: 96px;
            height: 28px;
            line-height: 28px;
            text-align: center;
            border-radius: 14px;
            font-size: 14px;
        }
        .btn0{
            background-color: #2AC092;
            color: #fff;
        }
        .btn1{
            border: #E6E6E6 1px solid;
        }
        .btn2{
            border: #E6E6E6 1px solid;
        }
    }

    .c_name {
        flex: 3;
    }

    .c_item {
        flex: 1;
    }

    .o_item {
        line-height: 80px;
    }
}</style>